package com.zhibi.util.apix;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import com.zhibi.util.http.HttpRespons;
import com.zhibi.util.http.HttpUtil;

public class ApixUtil {

	/**
	 * 得到天气
	 * @param city
	 * @return
	 */
	public static String getWeather(String city){
		String url = "http://a.apix.cn/apixlife/weather/weather?cityname="+city;
		Map<String, String> propertys = new HashMap<String, String>();
		propertys.put("apix-key", "5d80bd5c0c9a41454bc01c29b9fe1287");
		try {
			HttpRespons respons = HttpUtil.sendGet(url, null, propertys);
			return respons.getContent();
		} catch (IOException e) {
			e.printStackTrace();
			return "";
		}
	}
	
	/**
	 * 手机归属地查询
	 * @param phone
	 * @return
	 */
	public static String getPhoneAddress(String phone){
		String url = "http://a.apix.cn/apixlife/phone/phone?phone="+phone;
		Map<String, String> propertys = new HashMap<String, String>();
		propertys.put("apix-key", "afa82de08db04e7978953b1e2186b336");
		try {
			HttpRespons respons = HttpUtil.sendGet(url, null, propertys);
			return respons.getContent();
		} catch (IOException e) {
			e.printStackTrace();
			return "";
		}
	}
	
	public static void main(String[] args) {
		System.out.println(getWeather("北京"));
		System.out.println(getPhoneAddress("1530274359"));
	}
}
